/*
 * main.c
 *
 *  Created on: 19-01-2013
 *      Author: ja
 */

#include "stm32f10x.h"
#include "FreeRTOS.h"
#include "task.h"
#include "semphr.h"

#include "rtos_tasks.h"
#include <stdio.h>

// mutex used to guard access to USART resource
xSemaphoreHandle sem;

// -----------------------------------------------------------------------------
//  main
// -----------------------------------------------------------------------------
int main (void)
{
	printf("START\r\n");

	sem = xSemaphoreCreateMutex();

    // Create RTOS tasks
    if (pdPASS != xTaskCreate(TASK_LED1, ( signed portCHAR* ) "led1", configMINIMAL_STACK_SIZE, NULL, 2, NULL )) {
        // should never get here, unless there is a memory allocation problem
    }

    if (pdPASS != xTaskCreate(TASK_USART, ( signed portCHAR* ) "usart1", configMINIMAL_STACK_SIZE, NULL, 3, NULL )) {
        // should never get here, unless there is a memory allocation problem
    }

    if (pdPASS != xTaskCreate(TASK_USART, ( signed portCHAR* ) "usart2", configMINIMAL_STACK_SIZE, NULL, 3, NULL )) {
//         should never get here, unless there is a memory allocation problem
    }

    // start FreeRTOS scheduler - the RTOS takes control over the microcontroller
    vTaskStartScheduler();

    // program should never get here, unless there is a memory allocation problem
    while (1) {
        ;
    }

} /* main */

void NMI_Handler()
{
	printf("NMI\r\n");
}
void HardFault_Handler(void)
{
	printf("HARD FAULT\r\n");
}
void MemManage_Handler()
{
	printf("Mem Manage\r\n");
}
void BusFault_Handler()
{
	printf("BUS FAULT\r\n");
}
void UsageFault_Handler()
{
	printf("USAGE FAULT\r\n");
}

